﻿@using Janus.Cores.Tools
@using Janus.Mes.VO;
@model CalendarVO
@{
    Layout = null;
    string curYear = DateTime.Now.Year.ToString();
    string nextYear = (DateTime.Now.Year + 1).ToString();
    //IEnumerable<SelectListItem> lstYear = new List<SelectListItem> { new SelectListItem { Text = curYear, Value = curYear }, new SelectListItem { Text = nextYear, Value = nextYear } };
}

<style>
    .workDay {
        background-color: none;
    }

    .weekend {
        background-color: #CC6699;
    }

    .legalHoliday {
        background-color: #009966;
    }

    .daysOff {
        background-color: #FFFF00;
    }

    .calendarTable {
        border: 1px solid #b8d0d6;
        border-collapse: collapse; /* 边框合并属性  */
    }

        .calendarTable td {
            border: 1px solid #b8d0d6;
        }

    div.calendar_container_content td.clickable {
        cursor: pointer;
    }
</style>

<div id="calendar_container">
    <form method="post" action="BaseData/Calendar/create?OpID=@ViewData["OperateID"]" class="pageForm required-validate"
          onsubmit="return validateCallback(this, dialogAjaxDone);">
        @Html.ValidationSummary(true)
        @Html.HiddenFor(model => model.YearContentJson)
        @Html.HiddenFor(model => model.WorkCCode)
        @Html.HiddenFor(model => model.Year)

        <div class="calendar_container_header pageHeader">
            <div class="searchBar">
                <table class="searchContent">
                    <tr>
                        <td>
                            年份：
                        </td>
                        <td>
                            <select id="sltYear" class="WidthAsInputCombox" onchange="handleCalendarChange()">
                                <option value="@curYear">@curYear</option>
                                <option value="@nextYear">@nextYear</option>
                            </select>
                        </td>
                        <td>
                            工作中心：
                        </td>
                        <td>
                            <select id="sltWorkCCode" class="required WidthAsInputCombox">
                                <option value="">@HelperCommon.SelectDefaultValue</option>
                                <option value="S001">生产一课</option>
                                <option value="S002">生产二课</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <label><input class="calendarRadio" type="radio" name="rcreate" value="1"><span class="workDay">工作日</span></label>
                            <label><input class="calendarRadio" type="radio" name="rcreate" value="2"><span class="weekend">周末假日</span></label>
                            <label><input class="calendarRadio" type="radio" name="rcreate" value="3"><span class="legalHoliday">法定假日</span></label>
                            <label><input class="calendarRadio" type="radio" name="rcreate" value="4"><span class="daysOff">调休</span></label>
                        </td>
                    </tr>
                </table>
            </div>
        </div>

        <div id="calendar_container_out_content" layouth="95">

        </div>

        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit" onclick="HandleSubmit()">
                                保存
                            </button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">
                                返回列表
                            </button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>

<script type="text/javascript">
    $(function () {
        handleCalendarChange();
    });

    function handleCalendarChange() {
        var curDialog = $.pdialog.getCurrent();
        var year = $("#sltYear", curDialog).val();
        var url = "/BaseData/Calendar/CldrContent?syear=" + year;
        $("#calendar_container_out_content", curDialog).load(url);
    }

    function HandleSubmit() {
        var curDialog = $.pdialog.getCurrent();
        var json = "["
        $("tr.clickableRow", curDialog).find("td[cldr_type_org]").each(function () {
            json += "{";
            json += "'CDate':'" + $(this).attr("cldr_date") + "',";
            json += "'Ctype':'" + $(this).attr("cldr_type_new") + "'";
            json += "},";
        });
        json += "]";
        $("#YearContentJson", curDialog).val(json);
        $("#Year", curDialog).val($("#sltYear", curDialog).val());
        $("#WorkCCode", curDialog).val($("#sltWorkCCode", curDialog).val());
    }

</script>